package com.chengliang.bbs.service.impl;

import com.chengliang.bbs.entry.Message;
import com.chengliang.bbs.mapper.MessageMapper;
import com.chengliang.bbs.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author chengliang
 */
@Service
public class MessageServiceImpl implements MessageService  {

    @Autowired
    private MessageMapper messageMapper;

    @Override
    public Integer getMessageNumber(Integer userId) {
        return messageMapper.selectMessageNumberByUserId(userId);
    }

    @Override
    public List<Message> getMessageListBy(Integer userId) {
        return messageMapper.selectMessageByUserId(userId);
    }

    @Override
    public boolean read(Integer userId) {
        return messageMapper.updateMessageUnread(userId);
    }

    @Override
    public boolean removeMessageBy(Integer userId, Integer msgId) {
        return messageMapper.updateMessageDeleted(userId,msgId);
    }

    @Override
    public boolean removeMessageAll(Integer userId) {
        return messageMapper.updateMessageDeletedAll(userId);
    }


}
